package com.maopuyu.controllers;

import com.maopuyu.utils.CommonUtils;
import com.maopuyu.utils.TaoBaoUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.security.NoSuchAlgorithmException;

@RestController
@RequestMapping(value = "/api/taobao")
public class TaobaoController {

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String HelloWorld() {
        return "Hello Taobao";
    }

    @RequestMapping(value = "taoke", method = RequestMethod.GET)
    public String itemInfo(@RequestParam("jsonData") String jsonData)
            throws IOException, NoSuchAlgorithmException {
        return TaoBaoUtils.topRequest(CommonUtils.Json2Mapper(jsonData));
    }
}
